<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateMemberCardOrdersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        $table_name = 'member_card_orders';
        Schema::create($table_name, function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('tenant_id')->index()->comment('租户ID');
            $table->integer('user_id')->index()->comment('用户ID');
            $table->integer('member_card_id')->index()->comment('会员卡ID');
            $table->string('order_sn', 100)->comment('订单编号');
            $table->string('transaction_id', 100)->default('')->comment('微信支付流水号');
            $table->string('openid', 100)->default('')->comment('用户OPENID');
            $table->string('body', 100)->default('')->comment('支付body');
            $table->decimal('total_fee')->comment('订单总金额[元]');
            $table->boolean('is_paid')->default(false)->comment('是否已支付:1=是,0=否');
            $table->timestamp('paid_time')->nullable()->comment('支付时间');
            $table->timestamps();
        });
        add_table_comment($table_name, '会员卡订单表');
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('member_card_orders');
    }
}
